package zero.tech.games.gate.hot;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import zero.tech.core.data.Resp;
import zero.tech.core.data.SimpleUser;
import zero.tech.games.entity.games.ClubMemberWaterpak;
import zero.tech.games.gate.data.ExtensionRewardInfo;
import zero.tech.games.gate.data.res.ResExtensionReward;
import zero.tech.games.gate.mapper.ClubMemberWaterSummeryMapper;
import zero.tech.games.gate.mapper.ClubMemberWaterpakMapper;
import zero.tech.games.gate.service.api.ITradeService;

@Component
public class ExtensionUtil {

	@Autowired
	private ClubMemberWaterSummeryMapper clubMemberWaterSummeryMapper;
	@Autowired
	private ClubMemberWaterpakMapper clubMemberWaterpakMapper;
	@Autowired
	private ITradeService tradeService;
	public ResExtensionReward extensionReward(SimpleUser simpleUser, int club_id, Date begin, Date end) {
		int uid=simpleUser.getUid();
		ExtensionRewardInfo extensionRewardInfo = clubMemberWaterSummeryMapper.selectExtensionRewardInfo(club_id,uid,begin,end);
		ClubMemberWaterpak clubMemberWaterpak= clubMemberWaterpakMapper.getClubMemberWaterpak(club_id,uid);
		ResExtensionReward resExtensionReward = new ResExtensionReward();
		resExtensionReward.setZs_water(clubMemberWaterpak==null?0:extensionRewardInfo.getTotal_water_zs());
		resExtensionReward.setFzs_water(clubMemberWaterpak==null?0:extensionRewardInfo.getTotal_water_fzs());
		resExtensionReward.setZs_total_effect(clubMemberWaterpak==null?0:extensionRewardInfo.getTotal_water_zs_effect());
		resExtensionReward.setFzs_total_effect(clubMemberWaterpak==null?0:extensionRewardInfo.getTotal_water_fzs_effect());
		resExtensionReward.setWater_total(clubMemberWaterpak==null?0:extensionRewardInfo.getTotal_water_zs()+extensionRewardInfo.getTotal_water_fzs());
		resExtensionReward.setWater_total_effect(clubMemberWaterpak==null?0:extensionRewardInfo.getTotal_water_zs_effect()+extensionRewardInfo.getTotal_water_fzs_effect());
		resExtensionReward.setLeft_effect(clubMemberWaterpak==null?0:clubMemberWaterpak.getExtract_total());
		return resExtensionReward;
	}
	public Resp extensionRewardGet(SimpleUser simpleUser, int club_id, long gold) {
		int uid=simpleUser.getUid();
		//开始提取
		return tradeService.getExtensionReward(club_id,uid,gold);
	}

}
